Neste notebook, vamos codificar Redes Neurais de forma manual para tentar entender intuitivamente como elas são implementadas na prática.
In [ ]:
import numpy as np
In [ ]:
In [ ]:
In [ ]:
def linear(x, derivative=False):
return np.ones_like(x) if derivative else x
def relu(x, derivative=False):
if derivative:
x = np.where(x <= 0, 0, 1)
return np.maximum(0, x)
In [ ]:
x = np.array([[0.1, 0.2, 0.7]])
y = np.array([[1, 0, 0]])
w1 = np.array([[0.1, 0.2, 0.3], [0.3, 0.2, 0.7], [0.4, 0.3, 0.9]])
b1 = np.ones((1,3))
w2 = np.array([[0.2, 0.3, 0.5], [0.3, 0.5, 0.7], [0.6, 0.4, 0.8]])
b2 = np.ones((1,3))
w3 = np.array([[0.1, 0.4, 0.8], [0.3, 0.7, 0.2], [0.5, 0.2, 0.9]])
b3 = np.ones((1,3))
learning_rate = 0.01
for i in range(301):
# feedforward
# 1a camada
# 2a camada
# 3a camada
# backpropagation
# insira seu código aqui!
for w in [w1, w2, w3]:
print(w)